package com.leanin.form.service.impl;

import com.leanin.form.mapper.LeaninDataDictionaryMapper;
import com.leanin.form.model.LeaninDataDictionary;
import com.leanin.form.model.response.CommonCode;
import com.leanin.form.model.response.QueryResponseResult;
import com.leanin.form.model.response.QueryResult;
import com.leanin.form.service.DataDictionaryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author CPJ.
 * @date 2019/6/17.
 * @time 9:57.
 */
@Service
public class DataDictionaryServiceImpl implements DataDictionaryService {

    private static final Logger LOGGER = LoggerFactory.getLogger(DataDictionaryServiceImpl.class);

    @Autowired
    private LeaninDataDictionaryMapper leaninDataDictionaryMapper;

    @Override
    public QueryResponseResult findByCode(String code) {
        LOGGER.info("查询数据字典传递进来的参数:{}",code);
        List<LeaninDataDictionary> leaninDataDictionarys = leaninDataDictionaryMapper.findByCode(code);
        QueryResult queryResult =new QueryResult();
        queryResult.setList(leaninDataDictionarys);
        queryResult.setTotal(leaninDataDictionarys.size());
        return new QueryResponseResult(CommonCode.SUCCESS,queryResult);
    }
}
